package cn.itcast.controller;


import cn.ali.OssUtil;
import cn.itcast.pojo.Result;
//import cn.itcast.utils.OssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
public class UploadController {
    @Autowired
    private OssUtil ossUtil;
    @PostMapping
    public Result uploads(MultipartFile file) throws Exception {
        // 上传文件到OSS存储服务
        // 该代码块调用OSS Java SDK的快速启动类来执行文件上传操作
        String upload = ossUtil.upload(file);
        return upload != null ? Result.success(upload) : Result.erro("头像上传失败");
    }
}

